<?php
    require 'common.php';
    
    $db = new Database();
    $user = getUser($db);
    
    if($user['group'] < 2) {
        redirect('login.php');
        exit();
    }
    
    $page = new HtmlPage();
    $page->writeHeader(lang('SETTINGS_PAGENAME'));
    $page->writeTitle();
    $page->writeMenu('SETTINGS', $user);
    $page->write('<div class="content">', PUSH_TAB);
    
    $page->write('<h2>'.lang('SETTINGS_PAGENAME').'</h2>');
    $page->write('<form action="doupdatesettings.php" method="post">', PUSH_TAB);
    $page->write(getCsrfGuard());
    $page->write('<fieldset>', PUSH_TAB);
    $page->write('<legend>'.lang('SETTINGS_PAGENAME').'</legend>');
    
    $result = $db->query('SELECT name, value FROM '.config('DB_PREFIX').'misc');
    $i = -1;
    while($row = mysqli_fetch_assoc($result)) {
        $i++;
        if($i%2 == 0)
            $evenodd = 'even';
        else
            $evenodd = 'odd';
        $page->write('<div class="formentry '.$evenodd.'"><label><span>'.
            lang($row['name']).' :</span>'.
            '<input type="text" name="'.$row['name'].'" value="'.
            htmlEscape($row['value']).'" /></label></div>');
    }
    $page->write('</fieldset>', POP_TAB);
    $page->write('<input type="submit" value="'.lang('SAVE').'" />');
    $page->write('</form>', POP_TAB);
        
    $page->write('</div>', POP_TAB);
    $page->writeFooter();
?>